﻿using ApprovalFlow.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ApprovalFlow.Interface
{
    public interface IWorkflowController
    {

        /// <summary>
        /// 注册工作流
        /// </summary>
        /// <typeparam name="TWorkflow"></typeparam>
        void RegisterWorkflow<TWorkflow>() where TWorkflow : IWorkflow;

        /// <summary>
        /// 注册工作流
        /// </summary>
        /// <typeparam name="TWorkflow"></typeparam>
        /// <typeparam name="TData"></typeparam>
        void RegisterWorkflow<TWorkflow, TData>() where TWorkflow : IWorkflow<TData> where TData : new();


        /// <summary>
        /// 基于工作流模板开始一个新的审批实例。
        /// </summary>
        /// <param name="process_code"></param>
        /// <param name="data"></param>
        /// <param name="reference"></param>
        /// <returns>返回审批实例的id</returns>
        Task<string> StartWorkflow(string process_code, object data);

        /// <summary>
        /// 基于审批模板开始一个新的审批实例。
        /// </summary>
        /// <param name="process_code"></param>
        /// <param name="data"></param>
        /// <param name="reference"></param>
        /// <returns>返回审批实例的id</returns>
        Task<string> StartWorkflow(string process_code, object data, string reference);


        /// <summary>
        /// 基于审批模板开始一个新的审批实例。
        /// </summary>
        /// <param name="process_code">工作流的模板id</param>
        /// <param name="data">提交的数据</param>
        /// <param name="reference">引用的数据(审批实例业务编号。)</param>
        /// <param name="optional_list"></param>
        /// <param name="cc_list"></param>
        /// <param name="cc_position"></param>
        /// <returns>返回审批实例的id</returns>
        Task<string> StartWorkflow(string process_code, object data, string reference, Dictionary<string, string[]> optional_list = default, string[] cc_list = default, string cc_position = "START");

        /// <summary>
        /// 发布事件
        /// </summary>
        /// <param name="eventName">事件名称</param>
        /// <param name="eventKey">事件的key</param>
        /// <param name="eventData">事件的数据</param>
        /// <param name="effectiveDate">生效的事件</param>
        /// <returns></returns>
        Task PublishEvent(string eventKey, object eventData, DateTime? effectiveDate = null);

        ///// <summary>
        ///// Suspend the execution of a given workflow until .ResumeWorkflow is called
        ///// </summary>
        ///// <param name="workflowId"></param>
        ///// <returns></returns>
        //Task<bool> SuspendWorkflow(string workflowId);

        ///// <summary>
        ///// Resume a previously suspended workflow
        ///// </summary>
        ///// <param name="workflowId"></param>
        ///// <returns></returns>
        //Task<bool> ResumeWorkflow(string workflowId);

        /// <summary>
        /// 终止工作流的审批实例(撤销)。
        /// </summary>
        /// <param name="workflowId"></param>
        /// <returns></returns>
        Task TerminateWorkflow(string workflowId);
    }
}
